﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Templates
{
   public class Row:BaseElement
    {


         public Row(string strlocalname)
            : base(strlocalname)
        {

        }

         public Row(string strlocalname, 
         string caption,
         bool autoFitHeight,
         double height,
         bool hidden,
         ulong index,
         ulong span,
         string styleID, Cell cell)
         : this(strlocalname)
        {

            this.Caption=caption;
            this.AutoFitHeight=autoFitHeight;
            this.Height=height;
            this.Hidden=hidden;
            this.Index=index;
            this.Span=span;
            this.StyleID=styleID;
            this.Cell=cell;

        }


        string m_Caption;
        bool? m_AutoFitHeight;
        double? m_Height;
        bool? m_Hidden;
        ulong? m_Index;
        ulong? m_Span;
        string m_StyleID;

        Cell m_cell;

        public Cell Cell
        {
            get { return m_cell; }
            set { m_cell = value; }
        }



        public string Caption
        {
            get { return m_Caption; }
            set { m_Caption = value; }
        }
        public bool? AutoFitHeight
        {
            get { return m_AutoFitHeight; }
            set { m_AutoFitHeight = value; }
        }
        public double? Height
        {
            get { return m_Height; }
            set { m_Height = value; }
        }
        public bool? Hidden
        {
            get { return m_Hidden; }
            set { m_Hidden = value; }
        }
        public ulong? Index
        {
            get { return m_Index; }
            set { m_Index = value; }
        }
        public ulong? Span
        {
            get { return m_Span; }
            set { m_Span = value; }
        }
        public string StyleID
        {
            get { return m_StyleID; }
            set { m_StyleID = value; }
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if(!string.IsNullOrEmpty(this.Caption))
                dic.Add("Caption", this.Caption);

            if(this.AutoFitHeight != null)
                dic.Add("AutoFitHeight", this.AutoFitHeight.ToByte().ToString());

            if(this.Height != null)
                dic.Add("Height", this.Height.ToString());

            if(this.Hidden != null)
                dic.Add("Hidden", this.Hidden.ToByte().ToString());

            if(this.Index != null)
                dic.Add("Index", this.Index.ToString());

            if(this.Span != null)
                dic.Add("Span", this.Span.ToString());

            if(this.StyleID != null)
                dic.Add("StyleID", this.StyleID.ToString());
           
            return dic;
        }

        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if(this.Cell !=null)
                dic.Add("Cell", this.Cell.ToString());
            return dic;
        }

        protected override void SetDefaults()
        {
            return;
        }

        internal override string GetAttributeNamespace()
        {
            return Contstants.SpredsheetAttributePrefix;
        }

        internal override string GetAttributeNamespaceURI()
        {
            return Contstants.SpredsheetAttributeNamespace;
        }
    }
}






